package com.book.bookprojectapplication.write.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.book.bookprojectapplication.R;
import com.book.bookprojectapplication.write.activity.WriteDecorateActivity;

public class WriteDecoArrayFragment extends Fragment{

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View v = inflater.inflate(R.layout.fragmentwritedecoarray, container, false);

		ImageView writeDecoArrayLeft = (ImageView)v.findViewById(R.id.writedecoarrayleft);
		ImageView writeDecoArrayCenter = (ImageView)v.findViewById(R.id.writedecoarraycenter);
		ImageView writeDecoArrayRight = (ImageView)v.findViewById(R.id.writedecoarrayright);
		
		ImageView writeDecoArrayLeft2 = (ImageView)v.findViewById(R.id.writedecoarrayleft2);
		ImageView writeDecoArrayCenter2 = (ImageView)v.findViewById(R.id.writedecoarraycenter2);
		ImageView writeDecoArrayRight2 = (ImageView)v.findViewById(R.id.writedecoarrayright2);
		
		writeDecoArrayLeft.setOnClickListener(writeDecoArrayListener1);
		writeDecoArrayCenter.setOnClickListener(writeDecoArrayListener1);
		writeDecoArrayRight.setOnClickListener(writeDecoArrayListener1);
		
		writeDecoArrayLeft2.setOnClickListener(writeDecoArrayListener2);
		writeDecoArrayCenter2.setOnClickListener(writeDecoArrayListener2);
		writeDecoArrayRight2.setOnClickListener(writeDecoArrayListener2);

		return v;
	}
	OnClickListener writeDecoArrayListener1 = new OnClickListener(){
		@Override
		public void onClick(View v) {

			switch (v.getId()) {
			case R.id.writedecoarrayleft:			
				WriteDecorateActivity.setArrayEdit(Gravity.LEFT);
				break;
			case R.id.writedecoarraycenter:
				WriteDecorateActivity.setArrayEdit(Gravity.CENTER_HORIZONTAL);
				break;

			case R.id.writedecoarrayright:
				WriteDecorateActivity.setArrayEdit(Gravity.RIGHT);
				break;

			}

		}
	};
	
	OnClickListener writeDecoArrayListener2 = new OnClickListener(){
		@Override
		public void onClick(View v) {

			switch (v.getId()) {
			case R.id.writedecoarrayleft2:			
				WriteDecorateActivity.setArray(RelativeLayout.ALIGN_PARENT_LEFT);
				
				break;
			case R.id.writedecoarraycenter2:
				WriteDecorateActivity.setArray(RelativeLayout.CENTER_HORIZONTAL);
				break;

			case R.id.writedecoarrayright2:
				WriteDecorateActivity.setArray(RelativeLayout.ALIGN_PARENT_RIGHT);
				break;

			}

		}
	};

	

}
